package net.xiduth.game.player.dialogues.auto;


import net.xiduth.game.World;
import net.xiduth.game.WorldTile;
import net.xiduth.game.player.content.Magic;
import net.xiduth.game.player.dialogues.Dialogue;

public class SavedLocation extends Dialogue {

	@Override
	public void start() {
		sendOptionsDialogue("Select an Option",
				"Save location.", "Teleport to saved location.");
	}

	@Override
	public void run(int interfaceId, int componentId) {
		if (stage == -1 && componentId == OPTION_1) {
			if (!World.canMoveNPC(player.getPlane(), player.getX(),
					player.getY(), 3) || !player.canSpawn()) {
				player.sm("<col=ff0000>You can not save your location here.");
			} else {
			player.playerSavedX = player.getX();
			player.playerSavedY = player.getY();
			player.playerSavedZ = player.getPlane();
			player.sm("<col=00ff00>You successfully saved your location.");
			}
				end();
				return;
		} else {
			Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(player.playerSavedX,
					player.playerSavedY, player.playerSavedZ));
		}
	}

	@Override
	public void finish() {

	}
}